<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">考试公告管理</el-breadcrumb-item>
      <el-breadcrumb-item>考试公告列表</el-breadcrumb-item>
    </el-breadcrumb>
    <el-divider></el-divider>

    <el-container>
      <el-aside id="aside" width="200px">
        <el-menu
            class="el-menu-vertical-demo"
            @select="handleSelect"
            background-color="#ffffff"
            text-color="#000"
            active-text-color="#000"
            v-for="p in info"
        >
          <el-menu-item :index="p.id.toString()">
            <span slot="title">{{ p.title }}</span>
          </el-menu-item>
        </el-menu>
      </el-aside>
      <el-main id="main">
        <div style="width: 500px;margin-left: 250px">
          <h1 id="title">
            {{ message.title }}
          </h1>
          <h2 id="title-2">
            创建时间:{{ message.createTime }}
          </h2>
          <div id="content">
            {{ message.content }}
          </div>
        </div>

      </el-main>
    </el-container>
  </div>
</template>
<style>
#aside {
  position: absolute;
  left: 353px;
  top: 50px;
  bottom: 0px;
}

#main {
  text-align: left;
  position: absolute;
  left: 552px;
  right: 0px;
  top: 50px;
  bottom: 0px;
}

#title {
  text-align: center;
  font-size: 30px;
}

#title-2 {
  text-align: center;
  font-size: 12px;
}

#content {
  width: 600px;
  text-align: center;
  font-size: 24px;
  margin: 0 auto;
}
</style>
<script>
export default {
  data() {
    return {
      info: '',
      message: ''
      // activeIndex:'1'
    }
  },
  methods: {
    handleSelect(key, keyPath) {
      console.log(key, keyPath);
      let url = "http://120.77.154.166:8080/info/" + key + "/select";
      console.log('url = ' + url);
      this.axios
          .create({'headers': {'Authorization': localStorage.getItem('jwt')}})
          .get(url).then((response) => {
        let jsonResult = response.data;
        if (jsonResult.state == 20000) {
          this.message = jsonResult.data;
        }
      });
    },
    loadInfoList() {
      let url = "http://120.77.154.166:8080/info/list";
      console.log('url = ' + url);

      this.axios
          .create({'headers': {'Authorization': localStorage.getItem('jwt')}})
          .get(url).then((response) => {
        let jsonResult = response.data;
        if (jsonResult.state == 20000) {
          this.info = jsonResult.data;
        }
      });
    }
  },
  mounted() {
    this.loadInfoList();
  }
}
</script>
